'''
    该案例演示元祖
'''
# 创建元祖()
# tuple= (1,2,3,4,5)
# print(tuple)
# # 如果元祖是有一个元素,也要在括号中加一个逗号,不然就会当成一个运算符
# tuple1 = (1,)
# print(tuple1)

# # 这是列表推导式
# list1= [i for i in range(10)]
# print(list1,type(list1))   #[0, 1, 2, 3, 4, 5, 6, 7, 8, 9] <class 'list'>

# 使用元祖推导式创建元祖
# tuple_gen = (i for i in range(10))
# # print(tuple3,type(tuple3))   # <generator object <genexpr> at 0x00000158DC8219C0> <class 'generator'>
# # 需要转换
# tuple4 = tuple(tuple_gen)
# print(tuple4)  #(0, 1, 2, 3, 4, 5, 6, 7, 8, 9)

# 访问元祖
# tuple1 = (1, 2, 3,4,5,6)
# print(tuple1[1])  #2
# print(tuple1[0:-2]) #(1, 2, 3, 4)

# 元祖相加
# tuple1 = (1, 2, 3,4,5,6)
# tuple2 = ("a","b","c","d","e")
# print(tuple1 + tuple2)


# 元祖相乘
# tuple = (1,2,3,4,5)
# print(tuple*3)

# 检查是不是元祖成员
# print(100 in tuple)

# 获取元祖长度
# print(len(tuple))

# 最大值,最小值,求和
# print(max(tuple))
# print(min(tuple))
# print(sum(tuple))


# 遍历元祖
# tuple = (1,2,3,4,5)
# for item in tuple:
#     print(item)

# for i in range(len(tuple)):
#     print(i)
#
# for i,v in enumerate(tuple):
#     print(i,v)


# tuple1 = (1,2,3,4,5)
# print(tuple1,id(tuple1))
# tuple2 =tuple1 + (110,200)
# print(tuple2,id(tuple2))

tuple1= (1,2,3,[5,7,8,9])
tuple1[-1].append(4)
print(tuple1)